Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

Use remove newlines filter #54

Merged
merged 2 commits into from
Jun 4, 2017
Merged

Conversation

djbe
Copy link
Member

@djbe djbe commented May 30, 2017

Updates the templates to use the new filter a bit.

@djbe djbe added this to the 2.0.0 milestone May 30, 2017
@djbe
Copy link
Member Author

djbe commented May 30, 2017

I think the filter might be improved if the remove spaces behaviour would strip whitespaces at the beginning and end of lines, something matching a regex like: \s+ (which includes newlines)

{% macro parametersBlock types %}{% for type in types %}p{{forloop.counter}}: {{type}}{% if not forloop.last %}, {% endif %}{% endfor %}{% endmacro %}
{% macro argumentsBlock types %}{% for type in types %}p{{forloop.counter}}{% if not forloop.last %}, {% endif %}{% endfor %}{% endmacro %}
{% macro parametersBlock types %}{% filter removeNewlines:"false" %}
{% for type in types %}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: I really wish Stencil had whitespace control like ejs & Liquid & other template engines, so that we could write {%- for type in types -%} and let the template engine remove leading whitespaces when we use the dash on the opening brackets of tags. I think Kyle still intends to add it for Stencil 1.0 but it's still not in yet?

If Stencil plans to add it soon we can wait, if Kyle thinks he'll need more time for that we could imagine using a simplified version of it (replacing ^\s*{%- with {% in the template text before passing it to Stencil), a bit hacky but would work in the meantime. Only worth it if whitespace control isn't planned to be added too Stencil proper anytime soon though, imho 😉

@djbe
Copy link
Member Author

djbe commented Jun 2, 2017

Will update this once SwiftGen/StencilSwiftKit#48 is merged.

@djbe djbe force-pushed the feature/use-remove-newlines-filter branch from 1c3d43d to 60de9ee Compare June 4, 2017 21:44
@djbe djbe force-pushed the feature/use-remove-newlines-filter branch from 60de9ee to e9bb422 Compare June 4, 2017 21:46
@djbe djbe merged commit 2c2ca5c into master Jun 4, 2017
@djbe djbe deleted the feature/use-remove-newlines-filter branch June 4, 2017 21:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants